package user.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import user.dao.Result;
import user.dao.UserVo;
import user.service.impl.UserService;
import java.util.List;


@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    @PostMapping("/getUser")
    public Result getUser(@RequestBody UserVo userVo){
        List<UserVo> userVos = userService.get(userVo);
        Result result = new Result();
        result.setMsg("ok");
        result.setCode(200);
        result.setData(userVos);
        return result;
    }
    @PostMapping("/addUser")
    public String addUser(@RequestBody UserVo userVo){
         userService.add(userVo);
        return "ok";
    }

    @PostMapping("deleteUser")
    public String deleteUser(@RequestBody UserVo userVo){

        userService.delete(userVo);
        return "ok";
    }
    //修改
    @PostMapping("updateUser")
    public String updateUser(@RequestBody UserVo userVo){

        userService.update(userVo);
        return "ok";
    }

}
